package com.shxt.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.shxt.model.ValidateAdmin;
import com.shxt.pojo.Admin;

@WebServlet("/AdminValidate")
public class AdminValidate extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public AdminValidate() {
		super();
		// TODO Auto-generated constructor stub
	}

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=utf-8");
		String adminName = request.getParameter("adminname");
		String adminPassword = request.getParameter("adminpassword");
		System.out.println(adminName+"=="+adminPassword);
		ValidateAdmin va = new ValidateAdmin();
		Admin admin = va.validate(adminName, adminPassword);
		if(admin==null){
			
		}else{
			request.getSession().setAttribute("adminName", adminName);
			response.sendRedirect("Admin/index.html");
		}
	}

}
